/// Coder: Jose Ricardo Mello Viana - 2008
/// Bugs? e-mail me: zezim.ricardo@gmail.com

/**
 *
 * Author: Jose Ricardo (zezim)
 *
 * Data created: 09-05-08
 *
 **/

#ifndef _PAINT_CURSOR_H_
#define _PAINT_CURSOR_H_

#include "geomTypes/geomTypes.h"
#include "glslKernel/glslKernel.h"

#include <GL/glut.h>
#include <vector>
#include <math.h>

#define PI 3.1415926535897932384626433832795

using namespace std;

typedef float Number;
typedef Point<2, int> Point2i;
typedef Point<3, Number> Point3;
typedef Vector<3, Number> Vector3;
typedef Vector<4, Number> Color;

class PaintCursor {
public:
   /// Default constructor
   PaintCursor();

   /// Constructor
   /// @param x given x screen position
   /// @param y given y screen position
   PaintCursor(GLint x, GLint y);

   /// Default destructor
   virtual ~PaintCursor();

   /// Update world cursor position
   /// @param x given x screen position
   /// @param y given y screen position
   void updatePosition(GLint x, GLint y);

   /// Draw cursor
   void draw(GLuint prim = GL_LINE_LOOP);

   /// Increase zoom of cursor
   void in();

   /// Decrease zoom of cursor
   void out();

   /// Increase number of points in cursor
   void increase();

   /// Decrease number of points in cursor
   void decrease();

   /// Get cursor normal
   /// @return normal
//   Vector3 getNormal() { return normal; };

   /// Get cursor screen position
   /// @return screen position
   Point2i getScreenPosition() { return sPosition; };

   /// Get cursor color
   /// @return cursor color
   Color getColor(){ return color; };

   /// Set cursor color
   /// @param cursor color
   Color setColor(Color c){ color = c; };

   /// Represents paint cursor click
   void click() { clicked = true; };

   /// Represents paint cursor unclick
   void unclick() { clicked = false; };

   /// Get state of cursor
   /// @return clicked
   bool isClicked() { return clicked; };

   GLuint getNormalBuffer() { return normalBuffer; };

   void setNormalBuffer(GLuint nb) { normalBuffer = nb; };

   void setBuffersSize(int w, int h) { winw = w; winh = h; };

   int getBufferWidth() { return winw; };

   int getBufferHeight() { return winh; };

   GLint getSize() { return size; };

   Point2i getPosition() { return sPosition; };

private:
   Point2i sPosition;
   glslKernel *shader_cursor;

   Vector3 normal;

   GLint size;
   GLint number_points;

   Color color;

   bool clicked;

   GLuint normalBuffer;
   int winw, winh;
};

#endif /*_PAINT_CURSOR_H_*/
